package com.dmw.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class TestController {

    @GetMapping("/user")
    public String userAccess() {
        return "普通用户访问成功";
    }

    @PreAuthorize("hasRole('admin')")
    @GetMapping("/admin")
    public String adminAccess() {
        return "管理员访问成功";
    }
}